Component({
  options: {
    addGlobalClass: true
  },
  properties: {
    title: {
      type:String,
      value:''
    },
    items: {
      type:Array,
      value:[]
    },
    current: {
      type:Number,
      value:-1
    },
    style: {
      type:String,
      value:''
    }
  },
  data:{
    selected:0
  },
  lifetimes: {
    attached: function () {
      this.setData({selected:this.properties.current});
      //初始化时在引用页面显示默认规格
      if(this.properties.current<0)return;
      this.triggerEvent('select',{
        title: this.properties.title,
        current: this.properties.current,
        value: this.properties.items[this.properties.current].value
      });
    }
  },
  methods: {
    onSelect(e) {
      let _current=parseInt(e.target.dataset.index);
      this.setData({selected:_current});
      this.triggerEvent('select',{
        title: this.properties.title,
        current: _current,
        value: this.properties.items[_current].value
      });
    }
  }
})
